﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    partial class PropretyCamera : Form
    {
        NodeCamera nodecamera;
        public PropretyCamera(NodeCamera nodecamera)
        {
            InitializeComponent();

            this.nodecamera = nodecamera;
            this.InputMode.SelectedItem = nodecamera.InputMode.ToString();
            if (nodecamera.InputMode != NodeInputMode.InputMode_1)
            {
                this.numX.Value = (Decimal)nodecamera.Position.X;
                this.numY.Value = (Decimal)nodecamera.Position.Y;
                this.numScaleX.Value = (Decimal)nodecamera.Scale.X;
                this.numScaleY.Value = (Decimal)nodecamera.Scale.Y;
                this.numAngle.Value = (Decimal)nodecamera.Angle;
            }
            else
            {
                this.numX.Enabled = false;
                this.numY.Enabled = false;
                this.numScaleX.Enabled = false;
                this.numScaleY.Enabled = false;
                this.numAngle.Enabled = false;
            }
             
        }

        private void InputMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (InputMode.SelectedItem.ToString() == NodeInputMode.InputMode_1.ToString())
            {
                this.numX.Enabled = false;
                this.numY.Enabled = false;
                this.numScaleX.Enabled = false;
                this.numScaleY.Enabled = false;
                this.numAngle.Enabled = false;
            }
            else
            {
                this.numX.Enabled = true;
                this.numY.Enabled = true;
                this.numScaleX.Enabled = true;
                this.numScaleY.Enabled = true;
                this.numAngle.Enabled = true;
            }
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            String tempinputmode = InputMode.SelectedItem.ToString();
            String tempOldmode = nodecamera.InputMode.ToString();

            if (tempinputmode == NodeInputMode.None.ToString())
            {
                nodecamera.Position = new Microsoft.Xna.Framework.Vector2((float)this.numX.Value, (float)this.numY.Value);
                nodecamera.Scale = new Microsoft.Xna.Framework.Vector2((float)this.numScaleX.Value, (float)this.numScaleY.Value);
                nodecamera.Angle = (float)this.numAngle.Value;
                nodecamera.InputMode = AimGameLibrary.NodeInputMode.None;
            }
            else if (tempinputmode == NodeInputMode.InputMode_1.ToString())
            {
                nodecamera.InputMode = AimGameLibrary.NodeInputMode.InputMode_1;
            }

            if (tempinputmode != tempOldmode)
                nodecamera.SetupProprety();
        }

    }
}
